<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Home\Controller;
use User\Api\UserApi;

/**
 * 用户控制器
 * 包括用户中心，用户登录及注册
 */
class UserController extends HomeController {


	/* 登录页面 */
	public function login(){

		// 正常显示页面
		if (IS_GET) {
			$homeuser = I('session.onethink_home')['homeuser'];
			if ($homeuser) {
				redirect("Home/index.php");
			}else{
				$this->display();
			}
		}
		// 验证登录信息
		if (IS_POST) {
			$user = D('user');
			$user->userlogin();
		}

	}


	// 验证码
	public function Verify(){
		$user = D('user');
		$data = $user->code();
	}

	// 注销
	public function loginout(){
		session(null);
		redirect("Home/User/login");

	}

	public function register(){

		if (IS_GET) {
			$this->display();
		}
		if (IS_POST) {
			$user = D('user');
			$res = $user->registeruser();
		}
	}

	public function regist(){
		$user =D ('user');
		$res = $user->registe();
	}
}
